﻿' The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

''' <summary>
''' An empty page that can be used on its own or navigated to within a Frame.
''' </summary>
Public NotInheritable Class MessagePopup
    Inherits Page

    Public Event LeftButtonPressed()
    Public Event CentralButtonPressed()
    Public Event RightButtonPressed()

#Region "CONSTRUCTOR"

    Public Sub New(message As String, title As String, leftButtonText As String, centerButtonText As String, rightButtonText As String)

        InitializeComponent()

        Me.titleText.Text = title
        Me.messageText.Text = message

        If Me.messageText.Text = "" Then
            Me.messageText.Visibility = Windows.UI.Xaml.Visibility.Collapsed
        Else
            Me.messageText.Visibility = Windows.UI.Xaml.Visibility.Visible
        End If

        If leftButtonText = "" Then
            Me.leftButton.Visibility = Windows.UI.Xaml.Visibility.Collapsed
        Else
            Me.leftButton.Content = leftButtonText
        End If
        If centerButtonText = "" Then
            Me.centralButton.Visibility = Windows.UI.Xaml.Visibility.Collapsed
        Else
            Me.centralButton.Content = centerButtonText
        End If
        If rightButtonText = "" Then
            Me.rightButton.Visibility = Windows.UI.Xaml.Visibility.Collapsed
        Else
            Me.rightButton.Content = rightButtonText
        End If

        Dim bounds As Object = Window.Current.Bounds
        Me.RootPanel.Width = bounds.Width
        Me.RootPanel.Height = bounds.Height

    End Sub

#End Region

#Region "EVENTS"

    Private Sub leftButton_Click(sender As Object, e As RoutedEventArgs) Handles leftButton.Click

        RaiseEvent LeftButtonPressed()

    End Sub

    Private Sub centralButton_Click(sender As Object, e As RoutedEventArgs) Handles centralButton.Click

        RaiseEvent CentralButtonPressed()

    End Sub

    Private Sub rightButton_Click(sender As Object, e As RoutedEventArgs) Handles rightButton.Click

        RaiseEvent RightButtonPressed()

    End Sub

#End Region

#Region "Public Methods"

    Public Sub SetLeftButtonColor(newColor As Windows.UI.Color)

        Me.leftButton.Background = New SolidColorBrush(newColor)

    End Sub

    Public Sub SetCentralButtonColor(newColor As Windows.UI.Color)

        Me.centralButton.Background = New SolidColorBrush(newColor)

    End Sub

    Public Sub SetRightButtonColor(newColor As Windows.UI.Color)

        Me.rightButton.Background = New SolidColorBrush(newColor)

    End Sub

    Public Sub SetStyle(newStyle As MessagePopupStyle)

        With newStyle
            Me.backgroundBorder.Background = .BackgroundColor

            Me.titleText.FontFamily = .TitleFontFamily
            Me.titleText.FontSize = .TitleFontSize
            Me.titleText.Foreground = .TitleColor

            Me.messageText.FontFamily = .MessageFontFamily
            Me.messageText.FontSize = .MessageFontSize
            Me.messageText.Foreground = .MessageColor

            leftButton.FontFamily = .MessageFontFamily
            centralButton.FontFamily = .MessageFontFamily
            rightButton.FontFamily = .MessageFontFamily
        End With

    End Sub

#End Region

End Class

Public Class MessagePopupStyle

    Public BackgroundColor As Brush
    Public TitleColor As Brush
    Public MessageColor As Brush

    Public TitleFontFamily As FontFamily
    Public TitleFontSize As Integer

    Public MessageFontFamily As FontFamily
    Public MessageFontSize As Integer

End Class
